# coding=utf-8
# For prerequisites running the following sample, visit https://help.aliyun.com/document_detail/611472.html

from dashscope import Understanding
from http import HTTPStatus
import json


response = Understanding.call(
    model='opennlu-v1',
    sentence='老师今天表扬我了',
    labels='积极，消极，好事，坏事，中性',
    task='classification')

if response.status_code == HTTPStatus.OK:
    print(json.dumps(response.output, indent=4, ensure_ascii=False))
else:
    print('Code: %d, status: %s, message: %s' % (response.status_code, response.code, response.message))

# {
#     "rt": 0.06756415963172913,
#     "text": "积极;"
# }